﻿/**
 * The AudioTrack Library by Chris J. Rock. Aug 10, 2011
 * Check out chrisjrock.net and be a king among men.
 *
 * Copyright (c) 2011 Chris J. Rock
 * 
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 **/


package net.chrisjrock.sound.audioTrack.data
{
	import flash.media.SoundTransform;
	
	/**
	 * This is a basic object used for managing track data. It may represent the concatenation of multiple mixers in addition to a specific track.
	 * @author Christopher J. Rock
	 */
	public class AudioTrackData implements IAudioTrackData
	{
		protected var _mute:Boolean;
		protected var _solo:Boolean;
		
		protected var _pan:Number;
		protected var _volume:Number;
		
		public function AudioTrackData(volume:Number = 1 , pan:Number = 0 , mute:Boolean = false , solo:Boolean = false)
		{
			_volume = volume;
			_pan = pan;
			_mute = mute;
			_solo = solo;
		}
		
		/**
		 * @inheritDoc
		 * 
		 */		
		public function cloneData ():IAudioTrackData
		{
			return new AudioTrackData(_volume , _pan , _mute , _solo);
		}
		
		/**
		 * @inheritDoc
		 * 
		 */		
		public function getTransform ():SoundTransform
		{
			var transform:SoundTransform = new SoundTransform(_volume , _pan);
			if (_mute)
			{
				transform.volume = 0;
			}
			return transform;
		}
		
		/**
		 * @inheritDoc
		 * 
		 */		
		public function updateTransform (transform:SoundTransform = null):void
		{
			if (transform)
			{
				_pan = transform.pan;
				_volume = transform.volume;
			}
		}
		
		/**
		 * @inheritDoc
		 * 
		 */	
		public function get mute ():Boolean
		{
			return _mute;
		}
		
		/**
		 * @inheritDoc
		 * 
		 */	
		public function set mute (value:Boolean):void
		{
			_mute = value;
		}
		
		/**
		 * @inheritDoc
		 * 
		 */	
		public function get solo ():Boolean
		{
			return _solo;
		}
		
		/**
		 * @inheritDoc
		 * 
		 */	
		public function set solo (value:Boolean):void
		{
			_solo = value;
		}
		
		/**
		 * @inheritDoc
		 * 
		 */	
		public function get pan ():Number
		{
			return _pan;
		}
		
		/**
		 * @inheritDoc
		 * 
		 */	
		public function set pan (value:Number):void
		{
			_pan = value;
		}
		
		/**
		 * @inheritDoc
		 * 
		 */	
		public function get volume ():Number
		{
			return _volume;
		}
		
		/**
		 * @inheritDoc
		 * 
		 */	
		public function set volume (value:Number):void
		{
			_volume = value;
		}
	}
	
}